;;;;;;
;; Switch
;; define switches used to custom functions
;;;;;;

;; define if will use evil-mode
;; set it to nil to disable
(setq vim-enabled 1)
;; define if will use cnfont
(setq cnfonts-enabled 1)

;;;;
;; Packages
;;;;

;; Define package repositories
(require 'package)
;; (add-to-list 'package-archives
;; 	     '("melpa-stable" . "http://elpa.emacs-china.org/melpa-stable/") t)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)

;; load before modified
(package-initialize)

;; Define basical packages that i want to install
;; You may change these if you like
(defvar my-packages
       '(;; make handling lisp expressions much easier
	 paredit
	 
	 ;; allow ido usage in as many contexts as possible
	 ;;https://github.com/DarwinAwardWinner/ido-completing-read-plus
	 ido-completing-read+

	 ;; make it eaiser when use M-x to execute commands
	 ;; http://www.emacswiki.org/emacs/Smex
	 smex

	 ;; project navigation
	 projectile
         
         ;; rainbow-delimiters
         rainbow-delimiters
         
         ;; youdao-dictionary
         youdao-dictionary

	 ;; gotest
	 gotest
         
         ;; exec-path-from-shell
         exec-path-from-shell

         ;; htmlize. syntax highlighting in html export page
         htmlize
	 ))
;; Import envirement variables from user's shell while use OS X,
;; as OS X may not run a shell when login
(if (eq system-type 'darwin)
  (add-to-list 'my-packages 'exec-path-from-shell))
(if (eq vim-enabled 1)
  (add-to-list 'my-packages 'evil))
;; set up mono font for chinese characters
(if (eq cnfonts-enabled 1)
  (add-to-list 'my-packages 'cnfonts))


;; install basic package
(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

;;;;;;
;; Customization
;;;;;;
(add-to-list 'load-path "~/.emacs.d/customizations")

;; Sets up exec-path-from-shell so that Emacs will use the correct
;; env var
(load "shell-integration.el")
;; For editing emacs-lisps
(load "elisp-editing.el")
;; These customizations make it easier to navigate files, switch buffers
(load "navigation.el")
;; custom editing
(load "editing.el")
;; misc
(load "misc.el")
;; org mode settings
(load "setup-org.el")
;; setup clojure mode
(load "setup-clojure.el")
;; custom ui settings, keep ui settings load last 
(load "ui.el")
;; load youdao-dictionary settings
(load "setup-dictionary.el")
;; load clojure-tools
;;(load "my-clojure-tools.el")
;; load company-go
;;(load "company-go.el")
;; setup go
;;(load "setup-go.el")

;; setup slime
(load "setup-slime.el")
;; setup rust
(load "setup-rust.el")
;; setup plantuml
(load "setup-plantuml.el")


;; enable evil model
(if (eq vim-enabled 1)
    (evil-mode 1)
  (evil-mode 0))
(evil-mode 1)

;; setup cnfonts if enabled
(if (eq cnfonts-enabled 1)
    (progn 
      (cnfonts-enable)
      (setq cnfonts-use-system-type t)))

;; add this to make the font size adjust works
;;(define-key special-event-map [config-changed-event] 'ignore)


(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(0x0 geiser highlight-symbol slime-company plantuml-mode youdao-dictionary smex slime rainbow-delimiters racer projectile paredit nginx-mode json-mode ido-describe-bindings ido-completing-read+ htmlize gotest exec-path-from-shell evil emacsql-mysql company-go cnfonts cider cargo atom-one-dark-theme)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
